<template>
  <div class="file-expand-container" @click="handleToggleExpand">
    <template v-if="isExpand">
      <span v-if="isShowText">{{ retractText }}</span>
      <icon-font type="cap-icon-youjiantou-copy" class="expand-icon" />
    </template>
    <template v-else>
      <span v-if="isShowText">{{ expandText }}</span>
      <icon-font type="cap-icon-youjiantou2" class="expand-icon" />
    </template>
  </div>
</template>

<script>
  export default {
    name: 'FileExpandBtn',
    props: {
      isExpand: { // 展开/收起
        type: Boolean,
        default: true, // 展开
      },
      expandText: { // 展开文字
        type: String,
        default: $.i18n('common.relate.open.label'),
      },
      retractText: { // 收起文字
        type: String,
        default: $.i18n('common.retract.label'),
      },
      isShowText: { // 是否显示文字
        type: Boolean,
        default: true,
      },
    },
    methods: {
      handleToggleExpand() {
        this.$emit('expend');
      },
    },
  };
</script>

<style scoped lang="scss">
  .file-expand-container {
    display: flex;
    align-items: center;
    color: #666;

    &:hover {
      cursor: pointer;
      color: #1889ff;
    }

    > .expand-icon {
      margin-left: 4px;
    }
  }
</style>
